package algorithm;

import static net.ftng.commons.lang.utils.PrintUtils.println;

import java.util.TreeSet;

import net.ftng.commons.lang.utils.MathUtils;

/**
 * 数素
 * 
 * @author DengDefei
 * 
 */
public class PrimeNumber {

    public static void main(final String[] args) {

        int nextPrimeNumber = 2;
        int size = 168;
        TreeSet<Integer> primeNumbers = new TreeSet<Integer>();
        primeNumbers.add(nextPrimeNumber);
        for (; primeNumbers.size() < size;) {

            nextPrimeNumber++;
            boolean isPrimeNumber = true;
            for (int primeNumber : primeNumbers) {
                if (MathUtils.isAliquot(nextPrimeNumber, primeNumber)) {
                    isPrimeNumber = false;
                    break;
                }
            }
            if (isPrimeNumber)
                primeNumbers.add(nextPrimeNumber);
        }
        println(primeNumbers);
    }
}
